﻿/*
 * Created by SharpDevelop.
 * User: tdptcj
 * Date: 16/11/2011
 * Time: 8:42
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Windows.Controls;
using System.Windows.Data;

namespace MetaVideoEditorEvolved.ValidationRules
{
	/// <summary>
	/// Description of MappingGenreValidation.
	/// </summary>
	public class MappingGenreValidation : ValidationRule
	{
		public MappingGenreValidation()
		{
		}
		
		public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
		{
			var mapping = value as MetaVideoEditorEvolved.Engine.GenresMappingGenreMapping;
			if (mapping == null) {
				mapping = (value as BindingGroup).Items[0] as MetaVideoEditorEvolved.Engine.GenresMappingGenreMapping;
			}
			
			if (string.IsNullOrEmpty(mapping.Mapped)) {
				return new ValidationResult(false, "La zone de mappage doit être remplie");
			}
			
			if (string.IsNullOrEmpty(mapping.Original)) {
				return new ValidationResult(false, "Le genre doit être rempli");
			}
			
			if (string.IsNullOrEmpty(mapping.VideoType)) {
				return new ValidationResult(false, "Le type de vidéo doit être rempli");
			}
			return new ValidationResult(true, null);
		}
	}
}
